<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      div {
        width: 100px;
        height: 100px;
        background-color: orange;
        position: absolute;
        top: 0;
        left: 0;
      }
    </style>
  </head>
  <body>
    <div></div>
    <script>
      const divEl = document.querySelector("div");
      divEl.onclick = function () {
        startMove(this);
      };
      function startMove(dom) {
        clearInterval(dom.timer);
        let a = 2;
        let iSpeed = 20;
        dom.timer = setInterval(() => {
          iSpeed = iSpeed + a;
          divEl.style.left = divEl.offsetLeft + iSpeed + "px";
        }, 30);
      }
    </script>
  </body>
</html>
